package com.bacel.nb.product.core.domain;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * Created by Administrator on 2017/8/30 0030.
 */
@Entity
public class Device {
    private String sn;
    private String devicename;
    private String imei;
    private String sim;
    private String deviceinfo;
    private Double lat;
    private Double lng;
    private String location;
    private Timestamp createdate;
    private Devicetype devicetypeByDevicetypeid;
    private Deviceowner deviceownerByOwnerid;
    private App appByAppid;

    @Id
    @Column(name = "sn", nullable = false, length = 20)
    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    @Basic
    @Column(name = "devicename", nullable = true, length = 50)
    public String getDevicename() {
        return devicename;
    }

    public void setDevicename(String devicename) {
        this.devicename = devicename;
    }

    @Basic
    @Column(name = "imei", nullable = true, length = 50)
    public String getImei() {
        return imei;
    }

    public void setImei(String imei) {
        this.imei = imei;
    }

    @Basic
    @Column(name = "sim", nullable = true, length = 50)
    public String getSim() {
        return sim;
    }

    public void setSim(String sim) {
        this.sim = sim;
    }

    @Basic
    @Column(name = "deviceinfo", nullable = true, length = 50)
    public String getDeviceinfo() {
        return deviceinfo;
    }

    public void setDeviceinfo(String deviceinfo) {
        this.deviceinfo = deviceinfo;
    }

    @Basic
    @Column(name = "lat", nullable = true, precision = 6)
    public Double getLat() {
        return lat;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    @Basic
    @Column(name = "lng", nullable = true, precision = 6)
    public Double getLng() {
        return lng;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    @Basic
    @Column(name = "location", nullable = true, length = 100)
    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    @Basic
    @Column(name = "createdate", nullable = true)
    public Timestamp getCreatedate() {
        return createdate;
    }

    public void setCreatedate(Timestamp createdate) {
        this.createdate = createdate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Device device = (Device) o;

        if (sn != null ? !sn.equals(device.sn) : device.sn != null) return false;
        if (devicename != null ? !devicename.equals(device.devicename) : device.devicename != null) return false;
        if (imei != null ? !imei.equals(device.imei) : device.imei != null) return false;
        if (sim != null ? !sim.equals(device.sim) : device.sim != null) return false;
        if (deviceinfo != null ? !deviceinfo.equals(device.deviceinfo) : device.deviceinfo != null) return false;
        if (lat != null ? !lat.equals(device.lat) : device.lat != null) return false;
        if (lng != null ? !lng.equals(device.lng) : device.lng != null) return false;
        if (location != null ? !location.equals(device.location) : device.location != null) return false;
        if (createdate != null ? !createdate.equals(device.createdate) : device.createdate != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = sn != null ? sn.hashCode() : 0;
        result = 31 * result + (devicename != null ? devicename.hashCode() : 0);
        result = 31 * result + (imei != null ? imei.hashCode() : 0);
        result = 31 * result + (sim != null ? sim.hashCode() : 0);
        result = 31 * result + (deviceinfo != null ? deviceinfo.hashCode() : 0);
        result = 31 * result + (lat != null ? lat.hashCode() : 0);
        result = 31 * result + (lng != null ? lng.hashCode() : 0);
        result = 31 * result + (location != null ? location.hashCode() : 0);
        result = 31 * result + (createdate != null ? createdate.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "devicetypeid", referencedColumnName = "id",foreignKey = @ForeignKey(name = "device_ibfk_1"))
    public Devicetype getDevicetypeByDevicetypeid() {
        return devicetypeByDevicetypeid;
    }

    public void setDevicetypeByDevicetypeid(Devicetype devicetypeByDevicetypeid) {
        this.devicetypeByDevicetypeid = devicetypeByDevicetypeid;
    }

    @ManyToOne
    @JoinColumn(name = "ownerid", referencedColumnName = "id",foreignKey = @ForeignKey(name = "device_ibfk_2"))
    public Deviceowner getDeviceownerByOwnerid() {
        return deviceownerByOwnerid;
    }

    public void setDeviceownerByOwnerid(Deviceowner deviceownerByOwnerid) {
        this.deviceownerByOwnerid = deviceownerByOwnerid;
    }

    @ManyToOne
    @JoinColumn(name = "appid", referencedColumnName = "id",foreignKey = @ForeignKey(name = "device_ibfk_3"))
    public App getAppByAppid() {
        return appByAppid;
    }

    public void setAppByAppid(App appByAppid) {
        this.appByAppid = appByAppid;
    }

}
